/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ece.fr.edu.fac.controleur.outils;

import ece.fr.edu.fac.controleur.bd.DBCreation;
import ece.fr.edu.fac.controleur.oad.DAOAbstraite;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;

/**
 *
 * @author smarzoug
 */
public class ServletInitialization extends HttpServlet {
    
    DAOAbstraite dobject;
    public void init(ServletConfig sc)
    {
    	ServletContext ctx = sc.getServletContext();
    	dobject = new DAOAbstraite();
    	InputStream fis = ctx.getResourceAsStream(sc.getInitParameter("config"));
    	Properties props = new Properties();
   	 	try 
   	 	{
			props.load(fis);
		} 
   	 	catch (IOException ioe) {
   	 		
   	 		ioe.printStackTrace();
			
		}
    	
   	 	//dobject.setProperties(props);
    	
    	LoggerM.logger=new LoggerM().getLogger(props.getProperty("logfile"));
    	LoggerM.writeLogInfo("Logger Instantiation Réussie");
    	
    	try
    	{
    		new DBCreation();
    	}
    	catch(NullPointerException npe)
    	{
    		LoggerM.writeLogWarning("Echec lors de la connexion à la database");
    	}
    }
    
}
